//
//  KLError.h
//  yangtao
//
//  Created by Tommy on 14/10/8.
//  Copyright (c) 2014年 com.taobao. All rights reserved.
//

#ifndef yangtao_KLError_h
#define yangtao_KLError_h

#import <Foundation/Foundation.h>


#ifndef KLError
#define KLError(__domain,__code,__userInfo) \
        [NSError errorWithDomain:__domain code:__code userInfo:__userInfo]

#define KLSimpleError(__domain,__code,__desc) \
        [NSError errorWithDomain:__domain code:__code userInfo:@{NSLocalizedDescriptionKey: __desc?:@"未知错误"}]

#define KLSendError(__domain,__code,__userInfo) \
        [subscriber sendError:KLError(__domain,__code,__userInfo)]

#define KLSendSimpleError(__domain,__code,__desc) \
        [subscriber sendError:KLSimpleError(__domain,__code,__desc)]
#endif


#define KLErrorUserInfoCodeKey                 @"KLErrorUserInfoCodeKey"
#define KLErrorUserInfoSubcodeKey              @"KLErrorUserInfoSubcodeKey"
#define KLErrorUserInfoRawDataKey              @"KLErrorUserInfoRawDataKey"


#pragma mark -
#pragma mark Exception Error

//exception
#define KLExceptionErrorDomain              @"KLExceptionErrorDomain"

//login checkcode
typedef NS_ENUM(NSInteger, KLExceptionErrorCode){
    KLExceptionErrorCodeException
};


#pragma mark -
#pragma mark Transform Error

//exception
#define KLTransformErrorDomain              @"KLTransformErrorDomain"

//login checkcode
typedef NS_ENUM(NSInteger, KLTransformErrorCode){
    KLTransformErrorCodeUnrecognize,
    KLTransformErrorCodeFailed
};


#pragma mark -
#pragma mark Login Error

//login
#define KLLoginErrorDomain              @"KLLoginErrorDomain"

//login userinfo
#define KLLoginUserInfoCheckCodeUrlKey  @"KLLoginUserInfoCheckCodeUrlKey"
#define KLLoginUserInfoCheckCodeIdKey   @"KLLoginUserInfoCheckCodeIdKey"

//login checkcode
typedef NS_ENUM(NSInteger, KLLoginErrorCode){
    KLLoginErrorCodeAutoLoginNoNameOrNoToken,  //自动登陆，没有用户名或者token
    KLLoginErrorCodeSidInvalid,     //session 过期
    KLLoginErrorCodeNeedCheckCode,  //需要验证码
    KLLoginErrorCodeNetwork,    //网络问题
    KLLoginErrorCodeFailed
};



#pragma mark -
#pragma mark Network Error


#define KLNetWorkErrorDomain              @"KLNetWorkErrorDomain"
typedef NS_ENUM(NSInteger, KLNetWorkErrorCode){
    KLNetWorkErrorCodeUnknown,
    KLNetWorkErrorCodeTimeout,  //超时
    KLNetWorkErrorCodeAuthor,  //无权限
    KLNetWorkErrorCodeNotLogin, //未登陆
    KLNetWorkErrorCodeServer,   //服务器失败
    KLNetWorkErrorCodeOther,

};



#pragma mark -
#pragma mark Publish Permission Error

//#define KLPublishNeedInfoNotEnough              @"KLPublishNeedInfoNotEnough"
#define KLPublishPermissionErrorDomain              @"KLPublishPermissionErrorDomain"
typedef NS_ENUM(NSInteger, KLPublishPermissionErrorCode){
    KLPublishPermissionErrorCodeUnknown,
    KLPublishPermissionErrorCodeCannotPublish,
};




#pragma mark -
#pragma mark Upload Error

//#define KLPublishNeedInfoNotEnough              @"KLPublishNeedInfoNotEnough"
#define KLUploadErrorDomain              @"KLUploadErrorDomain"
typedef NS_ENUM(NSInteger, KLUploadErrorCode){
    KLUploadErrorCodeUnknown,
    KLUploadErrorCodeFileNotExist,
    KLUploadErrorCodeError,
};


#pragma mark -
#pragma mark PushCenter Error

//#define KLPublishNeedInfoNotEnough              @"KLPublishNeedInfoNotEnough"
#define KLPushCenterErrorDomain              @"KLPushCenterErrorDomain"
typedef NS_ENUM(NSInteger, KLPushCenterErrorCode){
    KLPushCenterErrorCodeUploadDeviceToken,
    KLPushCenterErrorCodeBind,
    KLPushCenterErrorCodeGetSubscribeCfg,
    KLPushCenterErrorCodeUpdateSubscribeCfg,
    KLPushCenterErrorCodeGetMsgBrief,
};











#endif
